package neu.soft.service.impl;

import lombok.val;
import neu.soft.entity.User;
import neu.soft.mapper.UserMapper;
import neu.soft.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    UserMapper userMapper;
    /**
     * @param user
     * 新增用户-自动生成uuid
     */
    @Override
    public int add(User user) {
       return  userMapper.add(user);
    }

    /**
     * @param user
     * 修改用户
     */
    @Override
    public int update(User user) {
       return userMapper.update(user);
    }

    /**
     * @param id
     */
    @Override
    public int delete(String id) {
        return userMapper.delete(id);
    }

    /**
     * @return
     * 查询所有用户
     */
    @Override
    public List<User> findAll() {
        List<User>userList = userMapper.findAll();
        return userList;
    }

    /**
     * @param username
     * 通过名字模糊查询用户
     * @return
     */
    @Override
    public List<User> findByName(String username) {
        List<User>userList = userMapper.findByName(username);
        return userList;
    }

    /**
     * @param uid
     * @return
     */
    @Override
    public User findById(String uid) {
        return userMapper.findById(uid);
    }
}
